package java67_7;

import java.util.Scanner;

public class FindInArray {

	public static void main(String[] args) {
		// 已知数组,输出全部;求和;查找在不在
		int[] ar = { 8, 4, 2, 1, 23, 34, 21 };
		// 输出
		for (int i = 0; i < ar.length; i++) {
			System.out.print(ar[i] + "\t");
		}
		// 输完换行
		System.out.println();
		// 求和
		int sum = 0;
		for (int i = 0; i < ar.length; i++) {
			sum = sum + ar[i];
		}
		System.out.println("和是:" + sum);
		Scanner in = new Scanner(System.in);
		System.out.print("请输入要查找的数字:");
		int k = in.nextInt();
		// ???
		boolean isIn = false;
		for (int i = 0; i < ar.length; i++) {
			if (ar[i] == k) {
				isIn = true;
				System.out.println(k + "在数组中");
				break;
			}
		}
		if (isIn == false) {
			System.out.println(k + "不在数组中");
		}
	}

}
